<template>
	<view class="tenancy">
		<view class="tenancy-top">
			<view class="tenancy-top-part">
				<view class="tenancy-top-part-top">
					<view class="tenancy-top-part-top-img">
						<image :src="imgurl + order_data.img" mode="widthFix" style="width: 90%;"></image>
					</view>
					<view class="tenancy-top-part-top-connet">
						<view class="tenancy-top-part-top-connet-top">
							<text>{{tanancy_data.goods_name}}</text>
						</view>
						<view class="tenancy-top-part-top-connet-top">
							<text style="color: #7f7f7f; font-size: 24rpx;">套餐：{{tanancy_data.setmeal_name}}</text>
						</view>
						<view class="tenancy-top-part-top-connet-top">
							<text style="color: #7f7f7f; font-size: 24rpx;">租期：{{tanancy_data.lease_time}}</text>
						</view>
						<view class="tenancy-top-part-top-connet-top"
							style="display: flex; justify-content: space-between;">
							<text>总租金：￥{{tanancy_data.total_rent}}(共{{tanancy_data.total_num}}期)</text>
							<text style="color: #7f7f7f;">x1</text>
						</view>
					</view>
				</view>
				<view class="tenancy-top-part-bottom">
					<view class="tenancy-top-part-bottom-part">
						<text style="font-size: 32rpx;">{{tanancy_data.first_rent}}</text>
						<text style="color: #7f7f7f; font-size: 24rpx;">首期租金(元)</text>
					</view>
					<view class="tenancy-top-part-bottom-part">
						<text style="font-size: 32rpx;">{{tanancy_data.total_rent}}</text>
						<text style="color: #7f7f7f; font-size: 24rpx;">总租金(元)</text>
					</view>
					<view class="tenancy-top-part-bottom-part">
						<text style="font-size: 32rpx;">{{tanancy_data.goods_price}}</text>
						<text style="color: #7f7f7f; font-size: 24rpx;">商品总价值(元)</text>
					</view>
				</view>
			</view>
		</view>
		<view class="tenancy-connet">
			<view class="tenancy-connnet-part">
				<view class="tenancy-connnet-part-top">
					<view class="tenancy-connnet-part-top-left">
						<text style="margin-left: 20rpx;">分期方式</text>
					</view>
					<view class="tenancy-connnet-part-top-right" @click="showmymodel()">
						<text style="color: #7f7f7f;">1个月租期间隔</text>
						<image src="../static/sureorder/bangzhu.png"
							style="width: 42rpx;height: 42rpx; margin-right: 20rpx;"></image>
					</view>
				</view>
				<view class="tenancy-connnet-part-listconnet">
					<view class="tenancy-connnet-part-listconnet-part">
						<view class="tenancy-connet-part-list">
							<view class="tenancy-connet-part-list-left"
								style="background-color: #f7f7f7; border-top:  #7f7f7f solid 2rpx;border-bottom:  #7f7f7f solid 2rpx;">
								<text style="color: black;">租数</text>
							</view>
							<view class="tenancy-connet-part-list-middle"
								style="background-color: #f7f7f7; border-top:  #7f7f7f solid 2rpx;border-bottom:  #7f7f7f solid 2rpx;">
								<text style="color: black;">租期</text>
							</view>
							<view class="tenancy-connet-part-list-right"
								style="background-color: #f7f7f7;border-top:  #7f7f7f solid 2rpx;border-bottom:  #7f7f7f solid 2rpx;">
								<text style="color: black;">每月租金</text>
							</view>
						</view>
						<view class="tenancy-connet-part-list" v-for="(item,index) in tanancy_data.order_lease"
							:key="index">
							<view class="tenancy-connet-part-list-left">
								<text>{{item.which_period}}</text>
							</view>
							<view class="tenancy-connet-part-list-middle">
								<text>{{item.lease_term}}</text>
							</view>
							<view class="tenancy-connet-part-list-right">
								<text>{{item.lease_price}}元</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="tenancy-bottom">
			<view class="tenancy-bottom-button" @click="back()">
				<text>返回</text>
			</view>
		</view>
		<MyModel v-show="mymodel" :mymodel="mymodel" @mymodelEvent="hidemodel">
			<template #title>
				分期方式
			</template>
			<template #list1>
				1.您当前选中的套餐租期为自定义租期商品,每期租赁周期为1个月,到租赁结束时间为止。
			</template>
			<template #list2>
				2.扣款日为每期开始租赁时间。
			</template>

		</MyModel>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mymodel: false,
				order_data: {},
				tanancy_data: {},
				imgurl: this.$apiUrl,
			}
		},
		onLoad(e) {
			console.log(JSON.parse(e.data))
			this.order_data = JSON.parse(e.data)
			uni.getStorage({
				key: 'userinfo',
				success: (res) => {
					uni.request({
						url: this.$apiUrl + 'Order/getOrderLeaseTerm',
						method: 'POST',
						header: {
							token: res.data.token
						},
						data: this.order_data,
						success: (e) => {
							this.tanancy_data = e.data.data
							console.log(this.tanancy_data)
							if (e.data.status != 200) {
								uni.showModal({
									title: '提示',
									content: '您还未授权登录，将为您跳转至用户页面，请点击头像登录',
									showCancel: false,
									success(event) {
										if (event.confirm) {
											uni.switchTab({
												url: '/pages/user/user'
											})
										}
									}
								})
							}
						}
					})
				},
				fail: (e) => {
					uni.showModal({
						title: '提示',
						content: '您还未授权登录，将为您跳转至用户页面，请点击头像登录',
						showCancel: false,
						success(event) {
							if (event.confirm) {
								uni.switchTab({
									url: '/pages/user/user'
								})
							}
						}
					})
				}
			})

		},
		methods: {
			back() {
				uni.navigateBack()
			},
			showmymodel() {
				this.mymodel = true
			},
			hidemodel(e) {
				this.mymodel = false
			},
		}
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #f7f7f7;
	}

	.hideY {
		overflow-y: hidden;
	}

	.tenancy {
		width: 100%;
		height: 100%;

	}

	.tenancy-top {
		width: 100%;
		height: 400rpx;
		background-color: white;
		display: flex;
		justify-content: center;
		align-items: flex-end;
	}

	.tenancy-top-part {
		width: 90%;
		height: 90%;

	}

	.tenancy-top-part-top {
		width: 100%;
		height: 200rpx;
		display: flex;
		justify-content: center;
		padding-bottom: 40rpx;
		border-bottom: #f7f7f7 solid 4rpx;

	}

	.tenancy-top-part-top-img {
		width: 200rpx;
		height: 200rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.tenancy-top-part-top-connet {
		width: calc(100% - 200rpx);
		height: 100%;
	}

	.tenancy-top-part-top-connet-top {
		width: 100%;
		height: 50rpx;
		font-size: 32rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}

	.tenancy-top-part-bottom {
		width: 100%;
		height: calc(100% - 244rpx);
		display: flex;
		justify-content: space-between;
	}

	.tenancy-top-part-bottom-part {
		width: 30%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;
		align-content: center;
	}

	.tenancy-connet {
		margin-top: 40rpx;
		width: 100%;
		height: 1080rpx;
		display: flex;
		justify-content: center;
		align-items: flex-start;
	}

	.tenancy-connnet-part {
		width: 90%;
		background-color: white;
		border-radius: 12rpx;
		padding-bottom: 20rpx;
	}

	.tenancy-connnet-part-top {
		width: 100%;
		height: 80rpx;
		background-color: white;
		display: flex;
		justify-content: center;
		padding-bottom: 20rpx;
		border-bottom: #f7f7f7 solid 2rpx;
	}

	.tenancy-connnet-part-top-left {
		width: 50%;
		height: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		font-size: 32rpx;
	}

	.tenancy-connnet-part-top-right {
		width: 50%;
		height: 100%;
		font-size: 32rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.tenancy-connnet-part-listconnet {
		width: 100%;
		height: calc(100% - 100rpx);
		display: flex;
		justify-content: center;
	}

	.tenancy-connet-part-list {
		width: 100%;
		height: 60rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-bottom: #7f7f7f solid 2rpx;
	}

	.tenancy-connnet-part-listconnet-part {
		width: 92%;
		height: 100%;
		margin-bottom: 20rpx;
	}

	.tenancy-connet-part-list-left {
		width: 20%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		color: #7f7f7f;
		border-right: #7f7f7f solid 2rpx;
		border-left: #7f7f7f solid 2rpx;
	}

	.tenancy-connet-part-list-middle {
		width: 50%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 26rpx;
		color: #7f7f7f;
		border-right: #7f7f7f solid 2rpx;
	}

	.tenancy-connet-part-list-right {
		width: 30%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		color: #7f7f7f;
		border-right: #7f7f7f solid 2rpx;
	}

	.tenancy-bottom {
		width: 100%;
		height: 100rpx;
		background-color: white;
		position: fixed;
		bottom: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		border-top: #f7f7f7 solid 2rpx;
	}

	.tenancy-bottom-button {
		width: 90%;
		height: 80%;
		background-color: red;
		color: white;
		font-size: 32rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 42rpx;
	}
</style>
